[ psqlodbc-Bugs-1010515 ] Small negative decimal values are mistaken for non-negative

Bugs item #1010515, was opened at 2008-11-28 11:32
You can respond by visiting:
http://pgfoundry.org/tracker/?func=detail&atid=538&aid=10105 15&group_id=1000125

Category: None
Group: None
Status: Open
Resolution: None
Priority: 3
Submitted By: Dominic Smith (dominic_smith)
Assigned to: Nobody (None)
Summary: Small negative decimal values are mistaken for non-negative

Initial Comment:
I originally found this problem in an older snapshot of 8.02.0400, however it seems to still exist in the current CVS copy.

In the method ResolveNumericParam (convert.c), there is a problem where resolving decimal values between 0 and -1, as they will be mistaken for being positive.

e.g. -0.01 becomes 0.01.

The problem is based on lines 3259:3262. The code in question:

o1val = ival / div;
o2val = ival % div;
if(0 == ns->sign)
olval *= -1;

The problem here is, in the case of -0.01, o1val is 0, and so 0 * -1 is still zero. When you come to format this as

sprintf(chrform, "%d.%0*d", o1val, ns->scale, o2val);

we quite obviously lose the negative sign in the value.

A very small aside, and a rather selfish request perhaps, the method 'trim()' in misc.c - is there any possibility of renaming this method (or at least make it static to 'connection.c' which is the only module that calls this) - the name is very common, and causes problems when the driver is dl_open()'d.

------------------------------------------------------------ ----------

You can respond by visiting:
http://pgfoundry.org/tracker/?func=detail&atid=538&aid=10105 15&group_id=1000125

--
Sent via pgsql-odbc mailing list (pgsql-odbc [at] postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-odbc
noreply [ Fr, 28 November 2008 12:32 ] [ ID #1978951 ]

Re: [ psqlodbc-Bugs-1010515 ] Small negative decimal valuesare mistaken for non-negative

noreply [at] pgfoundry.org wrote:
> A very small aside, and a rather selfish request perhaps, the method 'trim()' in misc.c - is there any possibility of renaming this method (or at least make it static to 'connection.c' which is the only module that calls this) - the name is very common, and causes problems when the driver is dl_open()'d.

Ideally, the ODBC driver could use an export list like libpq now does.

--
Sent via pgsql-odbc mailing list (pgsql-odbc [at] postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-odbc
Peter Eisentraut [ Fr, 28 November 2008 13:55 ] [ ID #1978952 ]
Datenbanken » gmane.comp.db.postgresql.odbc » [ psqlodbc-Bugs-1010515 ] Small negative decimal values are mistaken for non-negative

Vorheriges Thema: Conexiones desde clientes demasiado lentas
Nächstes Thema: [ psqlodbc-Bugs-1002054 ] SQLSetDescField with SQL_DESC_INDICATOR_PTR has no effect.